package cn.maihe.elg.operation.model.enums;

import java.util.Arrays;

/**
 * @Description 受理订单状态
 * @Author WJH
 * @Date 2021/03/25
 */
public enum AcceptOrderStatus {

    WAIT_FIRST_TRAIL(0, "待签署"),
    WAIT_SUBMIT_FIRST_TRAIL(1, "适用保函模板审核"),
    WAIT_TUNE_UP(2, "待尽调"),
    WAIT_SUBMIT_TUNE_UP(3, "待提交尽调资料（尽调退回重新上传或补充资料）"),
    WAIT_OFFER(4, "待报价"),
    WAIT_PAY(5, "待支付"),
    WAIT_PAY_CONFIRM(6, "待支付确认"),
    WAIT_OUT_GUARANTEE(7, "待出函"),
    HAS_OUT_GUARANTEE(8, "已出函"),
    FINISH(9, "交易完成"),
    CANCEL(10, "交易取消"),

    REVOKE_PROCESSING(11, "退保审核中"),
    REVOKE_SUCCESS(12, "退保成功"),
    REVOKE_FAIL(13, "退保失败"),
    CLOSE_APPLYING(14,"注销申请中"),
    SURRENDER_APPLYING(15,"退保申请中")
    ;
    /**
     * 受理订单类型
     */
    public static final Integer orderType = 0;

    private int status;
    private String desc;

    AcceptOrderStatus(int status, String desc) {
        this.status = status;
        this.desc = desc;
    }

    public int getStatus() {
        return status;
    }

    public String getStatusStr() {
        return String.valueOf(status);
    }

    public String getDesc() {
        return desc;
    }

    public static AcceptOrderStatus resolve(int status) {
        return Arrays.stream(values()).filter(v -> v.status == status).findFirst().orElseThrow(() -> new RuntimeException("受理订单状态值[" + status + "]有误"));
    }


    public static String getDescByStatus(Integer status) {
        try {
            AcceptOrderStatus acceptOrderStatus = resolve(status);
            return acceptOrderStatus.getDesc();
        } catch (Exception e) {
        }
        return "";
    }


}
